home *** CD-ROM | disk | FTP | other *** search
Java Source | 1995-12-31 | 496 b | 22 lines |
- /* Calculate future value */
- class calcfuture {
-
- public static void main(String args[]) {
-
- System.out.println(calc_future(0.0F,0.08f,4));
- }
-
- /* method doing the work */
- public static float calc_future (float principal,float interest,int years) {
-
- if (principal == 0.0) return 0.0f;
-
- float the_answer = principal;
-
- for (int y=0; y<years; ++y)
- the_answer += the_answer * interest;
-
- return the_answer;
- }
- }
-